package cn.coderdream.mdevstack

import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import cn.coderdream.anim.MAnim
import kotlinx.android.synthetic.main.activity_main.*
import java.text.SimpleDateFormat
import java.util.*

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        tv_big.setOnClickListener {

            MAnim.getInstance()
                .with(imageView, true)
                .scaleXY(1000, 1f, 0.1f, 1f)
                .scaleXY(1000, 1000, 1f, 3f, 1f)
                .scaleXY(1000, 1f, 0.1f, 1f)
                .alpha(2000, 1000, 1f, 0.3f, 1f)
                .start()

        }

        tv_small.setOnClickListener {
            MAnim.getInstance()
                .with(imageView, true)
                .scaleXY(1000, 1f, 0.1f, 1f)
                .call {
                    Log.d(
                        "MAnim",
                        "scaleXY:${SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(Date().time)}"
                    )
                }
                .translationX(2000, 0f, 300f, 200f, 400f, 100f, 500f, 0f)
                .call {
                    Log.d(
                        "MAnim",
                        "translationX:${SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(Date().time)}"
                    )
                }
                .translationY(2000, 0f, 300f, 200f, 400f, 100f, 500f, 0f)
                .call {
                    Log.d(
                        "MAnim",
                        "translationY:${SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(Date().time)}"
                    )
                }
                .translationXY(2000, 0f, 300f, 200f, 400f, 100f, 500f, 0f)
                .call {
                    Log.d(
                        "MAnim",
                        "translationXY:${SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(Date().time)}"
                    )
                }
                .rotation(1000, 0f, 220f)
                .call {
                    Log.d(
                        "MAnim",
                        "rotation:${SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(Date().time)}"
                    )
                }
                .start()
        }

        tv_big_small.setOnClickListener {
            MAnim.getInstance()
                .with(imageView, true)
                .rotationX(1000, 0f, 220f)
                .rotationY(1000, 0f, 220f)
                .rotationXY(1000, 0f, 220f)
                .start()
        }

        tv_small_big.setOnClickListener {
            MAnim.getInstance()
                .with(imageView, true)
                .rotationX(3000, 0f, 360f)
                .start()
        }
    }
}
